<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>项目产品报价方案</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>

<script type="text/javascript">

var update = '${update}';
console.log("支付表管理列表update:" + update);
var grid = null;
$(function () {
	initGrid();//grid
	  $("#searchBar").ligerForm();
	    $("#searchBtn").click(function(event) {
	         var form = new liger.get("searchBar");
	         var data = form.getData();
	         for (name in data){
	            grid.setParm(name,data[name]);
	         };
	        grid.reload();
	    });
	    initCondition();
});
	
  function initCondition(){}

  function clearBtn(){
	    $("#searchBar").ligerForm();
				var form = new liger.get("searchBar");
				form.setData({
					cstNm:"",
					splNm:"",
					prjNm:"",
					prjTypCd:"",
					buOrgCd:"",
					bizTypCd:"",
					lsDt:"",
					lsCntNo:"",
					timeType:"",
					strDate:"",
					endDate:"",
					prdStsCd:"",
					paySchNo:""
				 });
		}
//初始化列表
function initGrid(){
	var params = {};
	
	if(update=="0"){
		$("#transFlg").val(1);
		params = {
			transFlg:1	
		};
	}
	$("#grid").ligerGrid({
    	url: '<%=path%>/ref/fncprjprdpaysch/fncPrjPrdPaySchM/getPrjPrdPaySchMList.do',
    	method : 'get',
    	parms:params,
        columns: [
             { display: '合同编号', name: 'lsCntNo', minWidth: 150 ,align:'left',enabledSort:true},
             { display: '支付表号', name: 'paySchNo', minWidth: 200,align:'left',enabledSort:true},
                	 	
             { display: '承租人名称', name: 'cstNm', minWidth: 80,align:'left',enabledSort:true}, 
             getOpt1Columns(),
             getOpt2Columns(),
             getOpt3Columns(),
             getOpt4Columns(),
             getOpt5Columns(),
             getOpt6Columns(),
             getOpt7Columns(),
             getOpt8Columns()
             <%-- { display: '状态', name: 'prdStsCdNm', minWidth: 80,align:'left',enabledSort:true}, 	
             { display: '创建时间', name: 'crtTm', minWidth: 80,align:'left',render:renderDate,enabledSort:true}, 
             { display: '起租日', name: 'lsDt', minWidth: 80,align:'left',render:renderDate,enabledSort:true}, 	
             { display: '结清时间', name: 'stlDt', minWidth: 80,align:'left',render:renderDate,enabledSort:true}, 	
             { display: '拖回时间', name: 'backDt', minWidth: 80,align:'left',render:renderDate,enabledSort:true}, 	
             { display: '转正常时间', name: 'formDt', minWidth: 80,align:'left',render:renderDate,enabledSort:true}, 	
             { display: '申请单号', name: 'pNo', minWidth: 140 , 
	              	render: function (rowdata, rowindex, value, column) { 
	            		var h = '';
	            		var prdStsCd = rowdata.prdStsCd;
         			if(value&&value!="null"){
         				if(prdStsCd.indexOf(ProjectConstant.CODE_PRJ_PAY_SET)==0||prdStsCd.indexOf(ProjectConstant.CODE_PRJ_PAY_PRE_SET)==0){
		            		h+='<a href="javascript:commShowFlow(';
	            		    h+="'"+rowdata.pinstId+"',";
	            		    h+="'"+rowdata.audStsCd+"',";
	            		    h+="'"+rowdata.id+"',";
	            		    h+="'"+rowdata.prdStsCd+"',";
	            		    h+="'"+rowdata.buOrgCd+"'";
	            		    h+=')">'+value+'</a>'
         				}
         			}
                     return h;
         		},
	            	enabledSort:true}, 
             {
                display: '操作',
                isSort: false,
                width: 300,
                align:'center',
                isEllipsis: false,
                render: function (rowdata, rowindex, value){
					if(null != rowdata.bizFlag && rowdata.bizFlag == '2'){
						return "";
					}
                	var noticUrl ='<%=path%>/project/prjprdpayschm/exportRentNotice.do?id='+rowdata.id;
                  	var firstUrl ='<%=path%>/project/prjprdpayschm/exportFirstPayAmt.do?id='+rowdata.id;
                  	var payUrl ='<%=path%>/project/prjprdpayschm/exportPrjPrdPaySch.do?id='+rowdata.id;
                  	var payDetailUrl = '<%=path%>/project/prjprdpayschm/toPrjPrdPaySchMDetailPage.do?id='+rowdata.id;
                    var h="";
                    if(update != "0"){
		                    h+='<a class="sq-button-hasicon" href="javascript:addRickDep(';
		                    h+="'"+rowdata.id+"'";
		                    h+=')"><i class="sqBtnIco_3"></i>添加风险保证金</a>'
		                    var h2="";
		                    h2+='<a class="sq-button-hasicon" href="javascript:payDetail(';
		                    h2+="'"+rowdata.id+"'";
		                    h2+=')"><i class="sqBtnIco_2"></i>查看还款情况</a>';
		                    
		                    h2+='<a class="sq-button-hasicon" href="';
		                    h2+=noticUrl;
		                    h2+='"><i class="sqBtnIco_21"></i>导出起租通知书</a>';
		                    h2+='<a class="sq-button-hasicon" href="';
		                    h2+=firstUrl;
		                    h2+='"><i class="sqBtnIco_21"></i>导出首期款明细</a>';
		                    
		                    h2+='<a class="sq-button-hasicon" href="';
		                    h2+=payUrl;
		                    h2+='"><i class="sqBtnIco_21"></i>导出支付表</a>';
		                 if(rowdata.buOrgCd==ProjectConstant.CODE_BU_ORG_CD_ZK||rowdata.buOrgCd==ProjectConstant.CODE_BU_ORG_CD_YC||rowdata.buOrgCd==ProjectConstant.CODE_BU_ORG_CD_ZC){
		                	//发起提前结清流程
		                    h2+='<a class="sq-button-hasicon" href="javascript:applyNormalSett(';
		                    h2+="'"+rowdata.id+"',";
		                    h2+="'"+rowdata.prjId+"',";
		                    h2+="'"+rowdata.lsPd+"',";
		                    h2+="'"+rowdata.startLsPd+"',";
		                    h2+="'"+rowdata.paySchNo+"'";
		                    h2+=')"><i class="sqBtnIco_6"></i>正常结清</a>';
		                	//发起提前结清流程
		                    h2+='<a class="sq-button-hasicon" href="javascript:applyPerSett(';
		                    h2+="'"+rowdata.id+"',";
		                    h2+="'"+rowdata.prjId+"',";
		                    h2+="'"+rowdata.lsPd+"',";
		                    h2+="'"+rowdata.startLsPd+"',";
		                    h2+="'"+rowdata.paySchNo+"'";
		                    h2+=')"><i class="sqBtnIco_6"></i>提前结清</a>';
		                 }
		                  //乘用车 提前结清
		                 if(rowdata.buOrgCd==ProjectConstant.CODE_BU_ORG_CD_CAR){
		                      	  //发起提前结清流程
		                          h2+='<a class="sq-button-hasicon" href="javascript:applyCarPreSett(';
		                          h2+="'"+rowdata.id+"',";
		                          h2+="'"+rowdata.prjId+"',";
		                          h2+="'"+rowdata.lsPd+"',";
		                          h2+="'"+rowdata.startLsPd+"',";
		                          h2+="'"+rowdata.paySchNo+"'";
		                          h2+=')"><i class="sqBtnIco_6"></i>提前结清</a>';
		                          
		                          //发起正常结清流程
		                          h2+='<a class="sq-button-hasicon" href="javascript:applyCarNormalSett(';
		                          h2+="'"+rowdata.id+"',";
		                          h2+="'"+rowdata.prjId+"',";
		                          h2+="'"+rowdata.lsPd+"',";
		                          h2+="'"+rowdata.startLsPd+"',";
		                          h2+="'"+rowdata.paySchNo+"'";
		                          h2+=')"><i class="sqBtnIco_6"></i>正常结清</a>';
		                  }
		               	 if(rowdata.prdStsCdNm == "已拖回"){
		               		//发起追加费用
		                     h2+='<a class="sq-button-hasicon" href="javascript:additionalCharges(';
		                     h2+="'"+rowdata.id+"',";
		                     h2+="'"+rowdata.paySchNo+"'";
		                     h2+=')"><i class="sqBtnIco_6"></i>追加费用</a>';
		               	 }
                	     return h + SQ.dropLinks(h2);
		              }else{
		              	 h+='<a class="sq-button-hasicon" href="javascript:changeLsDt(';
		                   h+="'"+rowdata.id+"',";
		                   h+="'"+rowdata.lsDt+"'";
		                   h+=')">修改起租日</a>';
		                   h+='<a class="sq-button-hasicon" href="javascript:changePayPd(';
		                   h+="'"+rowdata.id+"',";
		                   h+="'"+rowdata.lsPd+"'";
		                   h+=')">修改提前还清期次</a>';
		              	return h;
		              }
                    
                }
            } --%>  
        ],
        pageSize:10,
        root:'rows',
        record:'total',
        hideLoadButton : true,
        width: '100%',
        height:'100%',
        heightDiff:-2,
        checkbox:true,
        allowUnSelectRow: true,
        alternatingRow: true,
        rownumbers:true,
        enabledEdit: false,
        fixedCellHeight: false,
        usePagerOnLessPagesize: true,
    });
	grid = liger.get("grid");
	grid.setHeight(300);
	
}

function getOpt1Columns(){
	var col1 = { display: '状态', name: 'prdStsCdNm', minWidth: 80,align:'left',enabledSort:true}; 	
	return col1;
}
function getOpt2Columns(){
	var col2 = { display: '创建时间', name: 'crtTm', minWidth: 80,align:'left',render:renderDate,enabledSort:true}; 
	return col2;
}
function getOpt3Columns(){
	var col3 = { display: '起租日', name: 'lsDt', minWidth: 80,align:'left',render:renderDate,enabledSort:true}; 	
	return col3;
}
function getOpt4Columns(){
	var col4 = { display: '结清时间', name: 'stlDt', minWidth: 80,align:'left',render:renderDate,enabledSort:true}; 	
	return col4;
}
function getOpt5Columns(){
	var col5 = { display: '拖回时间', name: 'backDt', minWidth: 80,align:'left',render:renderDate,enabledSort:true}; 	
	return col5;
}
function getOpt6Columns(){
	var col6 = { display: '转正常时间', name: 'formDt', minWidth: 80,align:'left',render:renderDate,enabledSort:true};	
	return col6;
}
function getOpt7Columns(){
    var col7 = {
        display: '申请单号', name: 'pNo', minWidth: 140,
        render: function (rowdata, rowindex, value, column) {
            var h = '';
            var prdStsCd = rowdata.prdStsCd;
            if (value && value != "null") {
                if (prdStsCd.indexOf(ProjectConstant.CODE_PRJ_PAY_SET) == 0 || prdStsCd.indexOf(ProjectConstant.CODE_PRJ_PAY_PRE_SET) == 0) {
                    h += '<a href="javascript:commShowFlow(' + rowindex + ')">' + value + '</a>';
                }
            }
            return h;
        },
        enabledSort: true
    };
    return col7;
}
function getOpt8Columns(){
    var col8 = {
       display: '操作',
       isSort: false,
       width: 200,
       align:'center',
       isEllipsis: false,
       render: function (rowdata, rowindex, value){
			if(null != rowdata.bizFlag && rowdata.bizFlag == '2'){
				return "";
			}
       	var noticUrl ='<%=path%>/project/prjprdpayschm/exportRentNotice.do?id='+rowdata.id;
         	var firstUrl ='<%=path%>/project/prjprdpayschm/exportFirstPayAmt.do?id='+rowdata.id;
         	var payUrl ='<%=path%>/project/prjprdpayschm/exportPrjPrdPaySch.do?id='+rowdata.id;
         	var payDetailUrl = '<%=path%>/project/prjprdpayschm/toPrjPrdPaySchMDetailPage.do?id='+rowdata.id;
           var h="";
                   h+='<a class="sq-button-hasicon" href="javascript:payDetail(';
                   h+="'"+rowdata.id+"'";
                   h+=')"><i class="sqBtnIco_2"></i>查看还款情况</a>';
           return h;
           
       }
   };
	return col8;
}

//显示流程
function commShowFlow(rowindex) {
    var rowdata = grid.getRow(rowindex);
    var _pInstId = rowdata.pinstId,
        _audStsCd = rowdata.audStsCd,
        _businessKey = rowdata.id,
        prdStsCd = rowdata.prdStsCd,
        buOrgCd = rowdata.buOrgCd,
        bizFlag = rowdata.bizFlag;

	if(StringUtils.isEmpty(_pInstId)){
		UIUtils.alertWarning(CommonConstant.C_P_INSTANCEID_NOT_HERE);
		return;
	}

	var _formUrl = "";
    if(buOrgCd==ProjectConstant.CODE_BU_ORG_CD_CAR){
    	if(prdStsCd.indexOf(ProjectConstant.CODE_PRJ_PAY_PRE_SET)==0){
			 _formUrl = "/project/prjprdpayschm/addCarPreSettleFeePage.do?isDetail=1"+"@@processInstanceId="+_pInstId+"@@paySchId=";
		}
    	if(prdStsCd.indexOf(ProjectConstant.CODE_PRJ_PAY_SET)==0){
			 _formUrl = "/project/prjprdpayschm/settleCarNormalAddFeePage.do?isDetail=1"+"@@processInstanceId="+_pInstId+"@@paySchId=";
		}
    }else{
        if (isFinancialInst(bizFlag)) {
            // 资管
            _formUrl = "/project/financialInst/showZGSettlePage.do?bankAct=1-1-1-1@@processInstanceId=" + _pInstId + "@@paySchId=";
        } else {
            if(prdStsCd.indexOf(ProjectConstant.CODE_PRJ_PAY_SET)==0){
                _formUrl = "/project/prjprdpayschm/settleAddFeePage.do?isDetail=1"+"@@processInstanceId="+_pInstId+"@@paySchId=";
            }
            if(prdStsCd.indexOf(ProjectConstant.CODE_PRJ_PAY_PRE_SET)==0){
                _formUrl = "/project/prjprdpayschm/addPreSettleFeePage.do?isDetail=1"+"@@processInstanceId="+_pInstId+"@@paySchId=";
            }
        }
    }

	//var _formUrl = "/project/audit/toAdditionalInfoPage.do?isDetail=1"+"@@processInstanceId="+_pInstId+"@@projectId=";
	var params = "?pInsId="+_pInstId+"&status="+_audStsCd+"&businessKey="+_businessKey+"&formUrl="+_formUrl;
	Add_navTab('tab_cst_invoice_flow_'+_businessKey,'查看流程',"<%=path%>/flow/flow/toFlowShowPageFowBus.do"+params);

}
//格式化为人民币格式
function renderAmt(rowdata, rowindex, value) {
    var h="￥" + FormatMoney(value)
    return h;
}

//格式化时间
function renderDate(rowdata, index, value){
	var dateStr = "";
	if(null != value&&value!=''){
		var date = new Date(value);
		dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
	}
	return dateStr;
}

function addRickDep(id){
    $.ligerDialog.open({title: '添加风险保证金信息',height: 300,width: 700, url: '<%=path%>/project/prjprdpayschm/toAddRickDepPage.do?id='+id,
    	   buttons: [{
                text: "保存", onclick: onSave, type: 'ok', cls: 'l-dialog-btn-ok'
            },
            {
                text: "取消", onclick: onCancel, type: 'cancel', cls: 'l-dialog-btn-no'
            }
        ]
    });
}

function changeLsDt(id,lsDt){
	if(lsDt=="null"){
		$.ligerDialog.open({width: 700,
	    	   buttons: [{
	                text: "保存", type: 'ok', cls: 'l-dialog-btn-ok', onclick: function(){
	                	changeSave(id);
	                }
	            },
	            {
	                text: "取消", type: 'cancel', cls: 'l-dialog-btn-no', onclick:function(){
	                	$.ligerDialog.hide();
	                }
	            }
	        ],
	        title: '修改起租日',
	        target: $("#changeLsDt")
	    });
	    var ligerForm = $("#changeLsDt_form").ligerForm({validate: true});
	    var form = new liger.get("changeLsDt_form");
		form.setData({
			lsDtParam:""
		 });
	}else{
		$.ligerDialog.SQalert({content: "只能修改起租日为空的支付表!",SQ_type: "error"});
	}
    
}

function changePayPd(id,lsPd){
		$.ligerDialog.open({width: 720,
	    	   buttons: [{
	                text: "保存", type: 'ok', cls: 'l-dialog-btn-ok', onclick: function(){
	                	changePayPdSave(id,lsPd);
	                }
	            },
	            {
	                text: "取消", type: 'cancel', cls: 'l-dialog-btn-no', onclick:function(){
	                	$.ligerDialog.hide();
	                }
	            }
	        ],
	        title: '修改提前还清期次',
	        target: $("#changePayPd")
	    });
	    var ligerForm = $("#changePayPd_form").ligerForm({validate: true});
	    var form = new liger.get("changePayPd_form");
		form.setData({
			payPdParam:""
		 });
		setPayPdOption(lsPd);
}

function setPayPdOption(lsPd){
	var lspd = parseInt(lsPd);
	liger.get("payPdParam").clearContent();
		var newOptions='<option value=""></option>';
	if(lspd>0){
	for(var i=1;i<lspd+1;i++){
		newOptions+='<option value="'+i+'">'+i+'期</option>';
		}
	}
    $("#payPdParam").html($(newOptions));
    liger.get("payPdParam").setSelect();
}

function changeSave(id){
	$.ajax({
		type: 'post',
		dataType:'json',
		data:{
			id:id,
			lsDt:$("#lsDtParam").val()
		},
		url: '<%=path%>/project/prjprdpayschm/modifyLsDt.do',
		success:function(msg){
			if(msg.success == 1){
            	$.ligerDialog.hide();
            	top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
				 grid.reload();
			 }else{
				 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
			 }
		}
	});
}

function changePayPdSave(id,lsPdMax){
	$.ajax({
		type: 'post',
		dataType:'json',
		data:{
			id:id,
			payPd:$("#payPdParam").val(),
			lsPdMax:lsPdMax
		},
		url: '<%=path%>/project/prjPrdPaySchD/modifyPayPd.do',
		success:function(msg){
			if(msg.success == 1){
            	$.ligerDialog.hide();
            	top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
				 grid.reload();
			 }else{
				 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
			 }
		}
	});
}

function payDetail(id){
	var payDetailUrl = '<%=path%>/ref/fncprjprdpaysch/fncPrjPrdPaySchM/toPrjPrdPaySchMDetailPage.do?id='+id;
	Add_navTab('tab_prj_quat_prps_pay'+id,'查看还款情况',payDetailUrl);
}
// 正常结清申请
function applyNormalSett(id, prjId, payPd, startLsPd, paySchNo, bizFlag) {
    var checkUrl = "/project/prjprdpayschm/checkPrjPaySchFlag.do";
    if (isFinancialInst(bizFlag)) {
        checkUrl = "/project/financialInst/checkApplyConstraints.do?settleType=1";
    }
    var callback = function () {
        grid.reload();
    }
    var params = {};
    params.paySchId = id;
    params.sett = "normal";
    $.ajax({
        type: 'post',
        dataType: 'json',
        data: params,
        url: '<%=path%>' + checkUrl,
        success: function (msg) {
            if (msg.success == 1) {
                if (isFinancialInst(bizFlag)) {
                    Add_navTab('tab_settle_financial_institution' + id, '资管正常结清选择期次', '<%=path%>/project/financialInst/showChooseSettlePdPage.do?settleType=1&prjId=' + prjId, callback);
                } else {
                    Add_navTab('tab_prj_quat_prps_pre_sett' + id, '支付表正常结清信息详情', '<%=path%>/project/prjprdpayschm/showChooseSettlePdPage.do?paySchId=' + id + '&&prjId=' + prjId + '&&payPd=' + payPd + '&&startLsPd=' + startLsPd + '&&paySchNo=' + paySchNo, callback);
                }
            } else {
                UIUtils.alertErrorHold1(msg.info);
                // top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
            }
        }
    });
}
// 判断业务标识是否为资管
function isFinancialInst(bizFlag) {
    if (bizFlag != '1' && bizFlag != '2') {
        return true;
    }
    return false;
}

// 提前结清申请
function applyPerSett(id, prjId, payPd, startLsPd, paySchNo, bizFlag) {
    var checkUrl = "/project/prjprdpayschm/checkPrjPaySchFlag.do";
    if (isFinancialInst(bizFlag)) {
        checkUrl = "/project/financialInst/checkApplyConstraints.do?settleType=2";
    }
    var callback = function () {
        grid.reload();
    }
    var params = {};
    params.paySchId = id;
    params.sett = "pre";
    $.ajax({
        type: 'post',
        dataType: 'json',
        data: params,
        url: '<%=path%>' + checkUrl,
        success: function (msg) {
            if (msg.success == 1) {
                if (isFinancialInst(bizFlag)) {
                    Add_navTab('tab_settle_financial_institution' + id, '资管提前结清选择期次', '<%=path%>/project/financialInst/showChooseSettlePdPage.do?settleType=2&prjId=' + prjId, callback);
                } else {
                    Add_navTab('tab_prj_quat_prps_pre_sett' + id, '支付表提前结清信息详情', '<%=path%>/project/prjprdpayschm/showChoosePreSettlePdPage.do?paySchId=' + id + '&&prjId=' + prjId + '&&payPd=' + payPd + '&&startLsPd=' + startLsPd + '&&paySchNo=' + paySchNo, callback);
                }
            } else {
                UIUtils.alertErrorHold1(msg.info);
            }
        }
    });
}
var onSave = function (item, Dialog) {
 //在子页面里绑定 frameElement.dialog.onOk = function () {}
	if (Dialog.onSave) Dialog.onSave();
};

var onCancel = function (item, Dialog) {
	 //在子页面里绑定 frameElement.dialog.onOk = function () {}
		if (Dialog.onCancel) Dialog.onCancel();
};

function detailBtn(prjPrdDtlId,id,prjPrdId,prjId){
	var editFlag = true;
	//支付表详情标志，true根据ID查询支付表记录，false表示
	Add_navTab('tab_prj_quat_prps'+id,'查看支付表','<%=path%>/project/prjprdpayschm/toAddPage.do?prjId='+prjId+'&&id='+id+'&&prjPrdDtlId='+prjPrdDtlId+'&&prjPrdId='+prjPrdId+'&&detailFlag='+editFlag);
 }

function iframeResize () {
    if (parent.mainApp) {
        parent.mainApp.parentTab.onResize();
    };
}
//汽车金融正常结清
function applyCarNormalSett(id,prjId,payPd,startLsPd,paySchNo,prjTypCd,prdTypCd){
    console.log("乘用车正常结清，项目类型：" + prjTypCd + " ,项目产品类型：" + prdTypCd);
    if (prjTypCd == 'DSFZGCP' || prjTypCd == 'DSFZGCT' || (prjTypCd == 'GHKD' && prdTypCd != '022')) {
        UIUtils.alertWarningHold1("三方资管不能发起结清流程!");
        return;
    }

	var callback = function(){
		 grid.reload();
	}
	var params = {};
	params.paySchId = id;
	params.sett = "normal";
	$.ajax({
		type: 'post',
		dataType:'json',
		data:params,
		url: '<%=path%>/project/prjprdpayschm/checkPrjPaySchFlag.do',
		success:function(msg){
			 if(msg.success == 1){
					Add_navTab('tab_prj_quat_prps_pre_sett'+id,'支付表正常结清信息详情','<%=path%>/project/prjprdpayschm/showCarNormalSettlePage.do?paySchId='+id+'&&prjId='+prjId+'&&payPd='+payPd+'&&startLsPd='+startLsPd+'&&paySchNo='+paySchNo,callback);
			 }else{
				 UIUtils.alertErrorHold1(msg.info);

				// top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
			 }
		}
	});
}


function applyCarPreSett(id,prjId,payPd,startLsPd,paySchNo,prjTypCd,prdTypCd){
    console.log("乘用车提前结清，项目类型：" + prjTypCd + " ,项目产品类型：" + prdTypCd);
    if (prjTypCd == 'DSFZGCP' || prjTypCd == 'DSFZGCT' || (prjTypCd == 'GHKD' && prdTypCd != '022')) {
        UIUtils.alertWarningHold1("三方资管不能发起结清流程!");
        return;
    }

	var callback = function(){
		 grid.reload();
	}
	var params = {};
	params.paySchId = id;
	params.sett = "pre";
	$.ajax({
		type: 'post',
		dataType:'json',
		data:params,
		url: '<%=path%>/project/prjprdpayschm/checkPrjPaySchFlag.do',
		success:function(msg){
			 if(msg.success == 1){
					Add_navTab('tab_prj_quat_prps_pre_sett'+id,'支付表提前结清信息详情','<%=path%>/project/prjprdpayschm/showCarPreSettlePage.do?paySchId='+id+'&&prjId='+prjId+'&&payPd='+payPd+'&&startLsPd='+startLsPd+'&&paySchNo='+paySchNo,callback);
			 }else{
				 UIUtils.alertErrorHold1(msg.info);
				// top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
			 }
		}
	});
}

	function additionalCharges(id,paySchNo){
		Add_navTab('tab_ass_sch_fee','已拖回追加费用项','<%=path%>/ass/assSchFee/toAssSchFeePage.do?paySchId='+id+'&&paySchNo='+paySchNo,callback);
	}
	var callback = function () {
		var form = new liger.get("searchBar");
        var data = form.getData();
        for (name in data){
           grid.setParm(name,data[name]);
        };
	    grid.reload();
	};
	
	  /* 导出 */
	function exportPrjPrdPaySchNew(id){
		var params = {};
		      params.id = id;
	        var url = '<%=path%>/project/prjprdpayschm/exportPrjPrdPaySchNew.do';
          var wait_dialog;
          $.ajax({
              type: 'post',
              dataType:'json',
              url: url,
              data:params,
              beforeSend:function(){
                  wait_dialog=$.ligerDialog.SQalert({content: '正在导出...',SQ_type: "waitting"});
              },
              success:function(msg){
                  wait_dialog.close();
                  if(msg.success == 1){
          	        var tempwindow= window.open("_blank");
          	        tempwindow.location=msg.data;
                  }else{
                      $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
                  }
              }
          });
		 }
    	  /* 导出起租提醒 */
      	function exportRentNoticeNew(id){
      		var params = {};
      		      params.id = id;
      	        var url = '<%=path%>/project/prjprdpayschm/exportRentNoticeNew.do';
                  var wait_dialog;
                  $.ajax({
                      type: 'post',
                      dataType:'json',
                      url: url,
                      data:params,
                      beforeSend:function(){
                          wait_dialog=$.ligerDialog.SQalert({content: '正在导出...',SQ_type: "waitting"});
                      },
                      success:function(msg){
                          wait_dialog.close();
                          if(msg.success == 1){
                  	        var tempwindow= window.open("_blank");
                  	        tempwindow.location=msg.data;
                          }else{
                              $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
                          }
                      }
                  });
      	  }
            	  /* 导出首期明细 */
              	function exportFirstPayAmtNew(id){
              		var params = {};
              		      params.id = id;
              	        var url = '<%=path%>/project/prjprdpayschm/exportFirstPayAmtNew.do';
                          var wait_dialog;
                          $.ajax({
                              type: 'post',
                              dataType:'json',
                              url: url,
                              data:params,
                              beforeSend:function(){
                                  wait_dialog=$.ligerDialog.SQalert({content: '正在导出...',SQ_type: "waitting"});
                              },
                              success:function(msg){
                                  wait_dialog.close();
                                  if(msg.success == 1){
                          	        var tempwindow= window.open("_blank");
                          	        tempwindow.location=msg.data;
                                  }else{
                                      $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
                                  }
                              }
                          });
  				}
            	  

              	function saveSynPay(){
              		$.ajax({
              			type: 'get',
              			dataType:'json',
              			
              			url: '<%=path%>/ref/fncprjprdpaysch/fncPrjPrdPaySchM/saveSynPay.do',
              			success:function(msg){
              				if(msg.success == 1){
              	            	$.ligerDialog.hide();
              	            	top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
              					 grid.reload();
              				 }else{
              					 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
              				 }
              			}
              		});
              	}
</script>

<body class="iframeBody">
	<div class="Wrapper">
        <div>
           <div id="pageInTab" class="pageInTab">
 <div class="searchArea">
    <form id="searchBar">
   <div class="fieldset1 clearFix">
   			<input id="transFlg" name="transFlg" style="display:none"/>
   		  <div class="fieldBox col_33" >
                <div class="label">客户名称</div>
                <div class="field">
                    <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="">
                </div>
            </div>
              <div class="fieldBox col_33" >
                <div class="label">项目名称</div>
                <div class="field">
                    <input name="prjNm" id="prjNm" type="text" class="ui-textbox" value="">
                </div>
            </div>
            <div class="fieldBox">
              <div class="label">项目类型</div>
                <div class="field">
                <select name="prjTypCd"  id="prjTypCd" >
                 <option value="  " selected="selected">--请选择--</option>
                 <c:forEach items="${projectTypeList}" var="opt">
                  <option value="${opt.key}">${opt.value}</option>
                 </c:forEach>
                </select>
                </div>
            </div>
              <div class="fieldBox">
            <div class="label">业务类型</div>
               <div class="field">
                 <select name="bizTypCd"  id="bizTypCd"  >
                  <option value="  " selected="selected">--请选择--</option>
                <c:forEach items="${bizTypeList}" var="opt">
                 <option value="${opt.key}">${opt.value}</option>
                </c:forEach>
               </select>
               </div>
            </div>
               <div class="fieldBox">
                <div class="label">所属事业部</div>
                <div class="field">
                    <select name="buOrgCd" id="buOrgCd">
                        <option value=" " seleted>请选择</option>
                        <c:forEach items="${orgListList }" var="org">
                        	<c:if test="${currentBuOrgCd == org.key }">
                        		<option value="${org.key }" selected>${org.value }</option>
                        	</c:if>
                        	<c:if test="${currentBuOrgCd != org.key }">
                        		<option value="${org.key }">${org.value }</option>
                        	</c:if>
                        </c:forEach>
                    </select>
                </div>
            </div>
              <div class="fieldBox col_33" >
                <div class="label">供应商名称</div>
                <div class="field">
                    <input name="splNm" id="splNm" type="text" class="ui-textbox" value="">
                </div>
            </div>
            
             <div class="fieldBox col_33" id="searchCstNmId" isHide="yes">
                <div class="label">起租日</div>
                <div class="field">
                    <input name="lsDt" id="lsDt" type="text" class="ui-datepicker" value="">
                </div>
            </div>
            <div class="fieldBox col_33" >
                <div class="label">合同编号</div>
                <div class="field">
                    <input name="lsCntNo" id="lsCntNo" type="text" class="ui-textbox" value="">
                </div>
            </div>
           <div class="fieldBox col_33" >
                <div class="label">是否删除</div>
                <div class="field">
                    <select name="isDel"  id="isDel"  >
		                  <option value="0"  selected="selected">否</option>
		                 <option value="1">是</option>
	               </select>
                </div>
            </div>
             <div class="fieldBox col_33"  isHide="yes">
                <div class="label">支付表状态</div>
                <div class="field">
	               <select name="prdStsCd"  id="prdStsCd"  >
	                  <option value="  " selected="selected">--请选择--</option>
	                <c:forEach items="${prdStsCdList}" var="opt">
	                 <option value="${opt.key}">${opt.value}</option>
	                </c:forEach>
	               </select>
                </div>
            </div>
              <div class="fieldBox col_33" >
                <div class="label">支付表号</div>
                <div class="field">
                    <input name="paySchNo" id="paySchNo" type="text" class="ui-textbox" value="">
                </div>
            </div>
             <div class="fieldBox col_33" id="searchCstNmId" isHide="yes">
                <div class="label">时间</div>
                <div class="field">
                 <select name="timeType"  id="timeType"  >
	                  <option value="  " selected="selected">--请选择--</option>
	                 <option value="stl">结清时间</option>
	                  <option value="back">拖回时间</option>
	                   <option value="form">转正常时间</option>
	               </select>
	               
                     <input name="strDate" id="strDate" type="text" class="ui-datepicker" value="">
                     <span>---</span>
                      <input name="endDate" id="endDate" type="text" class="ui-datepicker" value="">
                </div>
            </div>
            <div class="clearFix"></div>
   	<div class="btnsBox">
   			<span id="searchBtn"  class="sq-button sq-button-round">查询</span>
           <span id="clearBtn" onclick="clearBtn();" class="sq-button sq-button-round">清空</span>
           <span id="synBtn" onclick="saveSynPay();" class="sq-button sq-button-round">同步</span>
 	</div>
</div>
</form>
</div>
<div id="grid" class="sq-grid"></div>
</div>
	</div>
		</div>
<div id="changeLsDt" style="display:none">
    <form id="changeLsDt_form">
        <div class="fieldset1 tabel_col tabel_col_s noBorder clearFix">
            <div class="fieldBox col_50">
                <div class="label">起租日</div>
                <div class="field">
                    <input name="lsDtParam" id="lsDtParam" type="text" class="ui-datepicker" validate="{required:true}" value="">
                    <span class="requiredSymbol">*</span>
                </div>
            </div>
        </div>
        <div class="btnsBox">
            <span class="sq-button sq-button-hasicon Hide"><i class="sqBtnIco_10"></i>保存</span>
            <span class="sq-button sq-button-hasicon l-dialog-btn-cancel Hide"><i class="sqBtnIco_14"></i>取消</span>
        </div>
    </form>
</div>
<div id="changePayPd" style="display:none">
    <form id="changePayPd_form">
        <div class="fieldset1 tabel_col tabel_col_s noBorder clearFix">
            <div class="fieldBox col_50">
                <div class="label">期次</div>
                <div class="field">
                    <select name="payPdParam" id="payPdParam" validate="{required:true}">
                    </select>
                    <span class="requiredSymbol">*</span>
                </div>
            </div>
        </div>
        <div class="btnsBox">
            <span class="sq-button sq-button-hasicon Hide"><i class="sqBtnIco_10"></i>保存</span>
            <span class="sq-button sq-button-hasicon l-dialog-btn-cancel Hide"><i class="sqBtnIco_14"></i>取消</span>
        </div>
    </form>
</div>			
</body>
</html>